home *** CD-ROM | disk | FTP | other *** search
- /* biosdisk.c --- p560 */
- #include <stdio.h>
- #include <dos.h>
- #include <bios.h>
- #define DOS_DISPCHAR 2
- #define DISK_READ 2
- main()
- {
- int i, j, retry, strt;
- unsigned ch_out, status =0;
- char buf[512];
- int drive, head, track, sector, nsectors;
- /* Set up diskette information */
- drive = 0; /* Drive A, use 1 for drive B */
- head =0;
- track =0;
- sector =6; /* Location of first directory entry for DSDD diskettes*/
- nsectors = 1;
- /* Read sector making up to 3 retries. Retries are
- * necessary to make sure that any error is not due to
- * motor start-up delay. See explanation for error code
- * 80h above. */
- for(retry =0; retry<=3; retry++)
- {
- if((status = biosdisk(DISK_READ, drive, head,
- track, sector, nsectors, buf)) ==0)
- {
- printf("Read OK .\n");
- printf("First 10 directory entries are:\n");
- for(i=0; i<10;i++)
- {
- strt = 32*i; /* Each entry is 32 bytes */
- /* Each name is 11 bytes */
- for(j=0; j<11; j++)
- {
- ch_out = buf[strt+j];
- bdos(DOS_DISPCHAR, ch_out, 0);
- }
- printf("\n");
- }
- exit(0);
- }
- }
- /* Read failed despite 3 retries. Report error */
- printf("Error reading from diskette! status=%x\n", status);
- }